﻿using System;
using System.Collections.Generic;
using System.Text;
using DotNetCore.BannerManagement.DAL.Domain.dnc_AdvertiserRepositoryArtifacts;

namespace DotNetCore.BannerManagement.BLL
{
    public class AdvertiserManager
    {

        /// <summary>
        /// Will return a list of all advertisers in the database
        /// </summary>
        /// <returns></returns>
        public List<Domain.dnc_Advertiser> GetAllAdvertisers()
        {
            // Get repository
            dnc_AdvertiserRepository repository = new dnc_AdvertiserRepository();

            // return a list of all advertisers
            return repository.GetAllFromdnc_Advertiser();

        }

        /// <summary>
        /// Will return an advertiser entity based on the userID provided
        /// </summary>
        /// <param name="userId">The user id (string) of the advertiser</param>
        /// <returns></returns>
        public Domain.dnc_Advertiser GetAdvertiser(String userId)
        {
            // Get repository
            dnc_AdvertiserRepository repository = new dnc_AdvertiserRepository();

            // return a list of all advertisers
            return repository.Getdnc_AdvertiserByUserID(userId);

        }

        /// <summary>
        /// Will create an advertiser account
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public bool AddAdvertiser(string username)
        {
            dnc_AdvertiserRepository repository = new dnc_AdvertiserRepository();

            Domain.dnc_Advertiser advertiser = new Domain.dnc_Advertiser();
            advertiser.Name = username;
            advertiser.UserId = username;

            repository.Add(advertiser);

            return true;
          
        }
    }
}

